package dome8;

public class Test {
    public static void main(String[] args) {
        String str = "hello world hello bit" ;
        String[] result = str.split(" ",3) ;
        for(String s: result) {
            System.out.println(s);
        }
    }
    public static void main1(String[] args) {
        //使⽤字符串常量进⾏赋值

        String s1 = "hello bit";
        System.out.println(s1);
        //直接new String对象

        String s2 = new String("hello bit");
        System.out.println(s2);
        //使⽤字符数组进⾏构造

        char[] array = {'h','e','l','l','o','b','i','t'};
        String s3 = new String(array);
        System.out.println(s3);
        //使⽤字节数组构造对象

        byte[] bytes = {97,98,99,100};
        String s4 = new String(bytes);
        System.out.println(s4);
    }
}
